home *** CD-ROM | disk | FTP | other *** search
- /*RX
- * AREXX Name:Start_TeX.ttx Version:1.5JS Date:15-Nov-91
- *
-
- CED-File changed by Jan Schroeder for use with TTX.
-
- This AREXX script saves and compiles the current TTX view. The only
- (optional) argument is the format to be used. A '?' formatname will
- interactively ask for the format to use.
- *
- A command is send to the TeX server to compile the file. Hence a
- return value of 0 does not mean that the file compiled well, but only
- that the command was sent to the server and replied to.
- *
- AUTHOR:
- * J\"org H\"ohle, March 91
- *
- BUGS:
- virtex doesn't like filenames with blanks (and ARexx parses them
- hardly too), so avoid them in file, directory *and* device names.
- *
- Does not like names relative to the local root, like ":foo/bar"
- *
- FILES:
- ENV:TEXFORMAT: default format used
- REXX:namestruc
- *
- */
-
- /* OPTIONS FAILAT 3 */
-
- /*
- * IF ~SHOW('L','rexxsupport.library') THEN
- * IF ~ADDLIB('rexxsupport.library',0,-30,0) THEN DO
- * okay1 "Can't open 'rexxsupport.library'!"
- * EXIT 20
- * END
- */
-
- OPTIONS RESULTS
-
- portname = 'Start_TeX'
- script = 'TeX-server.rexx' /* no path required, message only */
-
- IF "" = GETCLIP("TEXQUERY") THEN askformat = 0
- ELSE askformat = 1 /* ask interactively for format name */
-
- PARSE ARG format .
- IF "?" = format THEN DO
- askformat= 1
- format = ""
- END
- ELSE IF '&' = LEFT(format,1) THEN
- format = SUBSTR(format,2)
-
- GetFilePath /* full filename */
- fullname=RESULT
-
- /* We need an absolute name */
- PARSE VALUE namestruc(fullname) WITH ivol idirs ibase .
-
- IF "" == SUBSTR(fullname, 1+ivol+idirs+ibase) | UPPER(RIGHT(fullname,3)) ~= "TEX" THEN DO
- SetStatusBar "Sorry, filename must end in `tex'."
- EXIT
- END
-
- IF 0 = ivol THEN DO
- direc = PRAGMA('d')
- IF RIGHT(direc,1)~='/' & RIGHT(direc,1)~=':' THEN direc=direc||'/'
- fullname = direc||fullname
- DROP direc
- END
- DROP ivol idirs ibase
-
- /* Save only if file has been modified */
- GetFileInfo
- PARSE VALUE RESULT WITH iline imod iname .
- If UPPER(imod) == "YES" THEN SaveFile
-
- IF (SHOW('P', portname)) THEN DO
- /* set the default format, modify it to suit your needs */
- envformat = mygetenv("TEXFORMAT")
- IF "" == format THEN DO
- format = envformat
- IF askformat | "" = envformat THEN DO
- IF "" = format THEN format = 'glplain'
-
- dum = RESULT
- RequestStr PROMPT Format? glplain
- nformat=RESULT
- /* if cancelled */
- IF dum ~= nformat THEN format = nformat
-
- END /* askformat */
- END /* format */
-
- /* If the server is already busy with some compilation, this will
- wait till compilation finishes, this may take a long time */
-
- if format ~= envformat THEN CALL mysetenv("TEXFORMAT",format)
-
- ADDRESS VALUE portname
- 'compile' format fullname
- END
- ELSE DO
- SetStatusBar "The TeX server 'script' is not running !"
- EXIT
- END
- EXIT
-
-
- mygetenv: procedure /* when will ARexx supply GetEnv/SetEnv ? */
- PARSE ARG name
-
- IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
- gives = readln(TEMPFILE)
- CALL close TEMPFILE
- END
- ELSE gives = ""
-
- RETURN gives
-
- mysetenv: procedure
- PARSE ARG name,content
-
- ADDRESS COMMAND "SetEnv" name content
-
- RETURN
-